package com.foreknow.demo3;

import java.util.Scanner;

public class Zy07302 {
        public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
            Scanner scanner = new Scanner(System.in);

            System.out.println("请输入日期（日 月 年）：");
            int day = scanner.nextInt();
            int month = scanner.nextInt();
            int year = scanner.nextInt();

            String season = "";
            boolean isValidDate = false;

            // 根据月份判断季节
            switch (month) {
                case 3: case 4: case 5:
                    season = "春";
                    break;
                case 6: case 7: case 8:
                    season = "夏";
                    break;
                case 9: case 10: case 11:
                    season = "秋";
                    break;
                case 12: case 1: case 2:
                    season = "冬";
                    break;
                default:
                    season = "无效月份";
                    break;
            }

            // 检查日期是否有效
            if (month >= 1 && month <= 12) {
                if (isLeapYear(year)) {
                    if (month == 2) {
                        if (day >= 1 && day <= 29) {
                            isValidDate = true;
                        }
                    } else if (month == 4 || month == 6 || month == 9 || month == 11) {
                        if (day >= 1 && day <= 30) {
                            isValidDate = true;
                        }
                    } else {
                        if (day >= 1 && day <= 31) {
                            isValidDate = true;
                        }
                    }
                } else {
                    if (month == 2) {
                        if (day >= 1 && day <= 28) {
                            isValidDate = true;
                        }
                    } else if (month == 4 || month == 6 || month == 9 || month == 11) {
                        if (day >= 1 && day <= 30) {
                            isValidDate = true;
                        }
                    } else {
                        if (day >= 1 && day <= 31) {
                            isValidDate = true;
                        }
                    }
                }
            }

            // 输出结果
            if (isValidDate) {
                System.out.println(year + "年" + month + "月" + day + "日 是有效的日期，属于 " + season + " 季。");
            } else {
                System.out.println(year + "年" + month + "月" + day + "日 不是有效的日期，或月份不在已知的季节范围内。");
            }
        }

        // 判断是否为闰年
        public static boolean isLeapYear(int year) {
            return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
        }
    }

